Imports SchemaCodeGen

Partial Public Class pages_Entitys_default : Inherits CPage

#Region "Querystring (Filters)"
	Public ReadOnly Property Search As String
		Get
			Return CWeb.RequestStr("search")
		End Get
	End Property

	'Rename or Delete:
	'Public ReadOnly Property ParentId As Integer
	'    Get
	'        Return CWeb.RequestStr("parentId")
	'    End Get
	'End Property
#End Region

#Region "Data"
	Public ReadOnly Property [Entitys]() As CEntityList
		Get
			Return CEntity.Cache.Search(txtSearch.Text)
		End Get
	End Property
#End Region

#Region "Event Handlers - Page"
	Protected Overrides Sub PageInit()
		'Populate Dropdowns


		'Search state (from querystring)
		txtSearch.Text = Me.Search

		'Display Results
		ctrlEntitys.Display(Me.Entitys)

		'Client-side
		Me.Form.DefaultFocus = txtSearch.ClientID  'txtCreate.ClientID
		Me.Form.DefaultButton = btnSearch.UniqueID  'CTextbox.OnReturnPress(txtSearch, btnSearch)
	End Sub
#End Region

#Region "Event Handlers - Form"
	Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
		Response.Redirect(CSitemap.Entitys(txtSearch.Text))
	End Sub
#End Region

#Region "Event Handlers - UserControl"
	Private Sub ctrl_AddClick() Handles ctrlEntitys.AddClick
		Response.Redirect(CSitemap.EntityAdd())
	End Sub
	Private Sub ctrl_ResortClick(ByVal sortBy As String, ByVal descending As Boolean, ByVal pageNumber As Integer) Handles ctrlEntitys.ResortClick
		Response.Redirect(CSitemap.Entitys(txtSearch.Text, New CPagingInfo(0, pageNumber - 1, sortBy, descending)))
	End Sub
#End Region

End Class
